import { S } from '../../s';
import { IPSAppDEUILogicLink } from '../../app/dataentity/ipsapp-deuilogic-link';
import { IPSDEUILogic } from './ipsdeuilogic';
import { IPSDEUILogicLink } from './ipsdeuilogic-link';
import { IPSDEUILogicLinkGroupCond } from './ipsdeuilogic-link-group-cond';
import { IPSDEUILogicNode } from './ipsdeuilogic-node';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEUILogicLinkImpl
  extends PSModelObjectImpl
  implements IPSDEUILogicLink, IPSAppDEUILogicLink
{
  protected dstpsdeuilogicnode: IPSDEUILogicNode;
  getDstPSDEUILogicNode(): IPSDEUILogicNode | null {
    if (this.dstpsdeuilogicnode != null) return this.dstpsdeuilogicnode;
    const value = this.M.getDstPSDEUILogicNode;
    if (value == null) {
      return;
    }
    const ipsdeuilogic = this.getParentPSModelObject(S._206) as IPSDEUILogic;
    if (ipsdeuilogic != null) {
      this.dstpsdeuilogicnode = ipsdeuilogic.findPSDEUILogicNode(value);
    }
    return this.dstpsdeuilogicnode;
  }

  get linkCond(): string {
    return this.M.linkCond;
  }

  get linkMode(): 0 | 1 | 2 | 3 | 9 {
    return this.M.linkMode;
  }

  protected psdeuilogiclinkgroupcond: IPSDEUILogicLinkGroupCond;
  getPSDEUILogicLinkGroupCond(): IPSDEUILogicLinkGroupCond | null {
    return (
      this.psdeuilogiclinkgroupcond ||
      (this.psdeuilogiclinkgroupcond = this.fillObjectModel(
        S._1e5,
        this.M.getPSDEUILogicLinkGroupCond,
        S._325,
      ) as IPSDEUILogicLinkGroupCond)
    );
  }

  protected srcpsdeuilogicnode: IPSDEUILogicNode;
  getSrcPSDEUILogicNode(): IPSDEUILogicNode | null {
    if (this.srcpsdeuilogicnode != null) return this.srcpsdeuilogicnode;
    const value = this.M.getSrcPSDEUILogicNode;
    if (value == null) {
      return;
    }
    const ipsdeuilogic = this.getParentPSModelObject(S._206) as IPSDEUILogic;
    if (ipsdeuilogic != null) {
      this.srcpsdeuilogicnode = ipsdeuilogic.findPSDEUILogicNode(value);
    }
    return this.srcpsdeuilogicnode;
  }

  get catchLink(): boolean {
    return this.M.catchLink != null ? this.M.catchLink : false;
  }

  get defaultLink(): boolean {
    return this.M.defaultLink != null ? this.M.defaultLink : false;
  }

  get fulfilledLink(): boolean {
    return this.M.fulfilledLink != null ? this.M.fulfilledLink : false;
  }

  get rejectedLink(): boolean {
    return this.M.rejectedLink != null ? this.M.rejectedLink : false;
  }

  get subCallLink(): boolean {
    return this.M.subCallLink != null ? this.M.subCallLink : false;
  }
  get cls(): string {
    return 'PSDEUILogicLinkImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._1e6 || cls == S._1e7) return true;
    return super.instanceof(cls);
  }
}
